home *** CD-ROM | disk | FTP | other *** search
-
- "Class implementing the Byte benchmarks.
-
- Written by Mat Davis."
-
- Object subclass: #Benchmark
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: '' !
-
- !Benchmark class methods ! !
-
-
- !Benchmark methods !
-
- calculate: nTimes
- "Perform the Byte calculation benchmark. Using 'print it' with
- the expression 'Benchmark new calculate: 5000' will print the
- error after 5000 iterations."
- | a b c |
- a := 271828 / 100000.
- b := 314159 / 100000.
- c := 1.
- 1 to: nTimes do: [ :i |
- c := c a.
- c := c b.
- c := c / a.
- c := c / b ].
- ^c - 1!
-
- diskRead: kBytes
- "Perform the Byte disk read benchmark. Evaluating the expression
- 'Benchmark new diskRead: 64' will read a 64K from the file
- A:TEST.DAT."
- | nr input |
- nr := kBytes 8.
- input := DiskA file: 'TEST.DAT'.
- 1 to: nr do: [ :i |
- input next: 128 ].
- input close.
- ^'Done'!
-
- diskWrite: kBytes
- "Perform the Byte disk write benchmark. Evaluating the expression
- 'Benchmark new diskWrite: 64' will create a 64K file named
- A:TEST.DAT."
- | a b nr output |
- a := '12345678123456781234567812345678'.
- b := a, a, a, a.
- nr := kBytes 8.
- output := DiskA file: 'TEST.DAT'.
- 1 to: nr do: [ :i |
- output nextPutAll: b ].
- output close.
- ^'Done'!
-
- sieve: size
- "Perform the Byte prime sieve benchmark. Evaluating the expression
- 'Benchmark new sieve: 8191' will return the number of primes from
- 1 to 8191."
- | flags count k |
- flags := Array new: size.
- count := 0.
- 1 to: size do: [ :i | flags at: i put: 1 ].
- 2 to: size do: [ :i |
- (flags at: i) == 1 ifTrue: [
- k := i + i.
- [ k > size ] whileFalse: [
- flags at: k put: 0.
- k := k + i ].
- count := count + 1 ] ].
- ^count! !
-